'''
    it just show that the sort function , just one by one to sort, one to all in the list,and then pop it (delete it )
it may be good by use the pointer (or it call index)
it can make the programming look simple
'''



def findSmallest(arr):
    smallest = arr[0]
    smallest_index = 0
    for i in range(1,len(arr)):
        if arr[i] < smallest:
            smallest = arr[i]
            smallest_index = i
    return smallest_index

def selectionsort(arr):
    new_arr = []
    for i in range(len(arr)):
        smallest = findSmallest(arr)
        new_arr.append(arr.pop(smallest))
        '''
            about how to use pop()? just delete the element in the list and return the element you delete ,by the way ,
        it default delete the last element.      
        '''
    return new_arr

print selectionsort([1,3,7,2,4,20])

